package com.qf.mes.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mes.common.PageParam;
import com.qf.mes.common.PageVO;
import com.qf.mes.common.UnitParam;
import com.qf.mes.entity.MdUnitMeasure;
import com.qf.mes.mapper.UnitMapper;
import com.qf.mes.service.UnitService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UnitServiceimpl implements UnitService {
    @Resource
    private UnitMapper unitMapper;
//    @Override
//    public PageVO<User> selectPage(PageParam param,UserParam userParam) {
//        PageHelper.startPage(param.getPageNum(),param.getPageSize());
//        List<User> users = userMapper.selectPage(userParam);
//        System.out.println(users);
//        PageInfo<User> pageInfo = new PageInfo<>(users);
//        if(users!=null){
//            return new PageVO<>(pageInfo.getTotal(),pageInfo.getList());
//        }
//        return null;
//    }
    @Override
    public PageVO<MdUnitMeasure> select(PageParam param, UnitParam unitParam) {
        PageHelper.startPage(param.getPageNum(),param.getPageSize());
        List<MdUnitMeasure> mdUnitMeasures = unitMapper.selectUnit(unitParam);
        PageInfo<MdUnitMeasure> pageInfo  = new PageInfo<>(mdUnitMeasures);
        if(mdUnitMeasures!=null){
            return new PageVO<>(pageInfo.getTotal(),pageInfo.getList());
        }


        return null;
    }


}
